/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
/**
 * Definition for singly-linked list.
 * struct ListNode {
 *     int val;
 *     struct ListNode *next;
 * };
 */
struct ListNode* sorucrhead;
bool dfs(struct ListNode* head){
    if (head != NULL) {
        if (dfs(head->next) != true) {
            return false;
        }
        if (sorucrhead->val != head->val) {
            return false;
        }
        sorucrhead = sorucrhead->next;
    }
    return true;
}

bool isPalindrome(struct ListNode* head){
    sorucrhead = head;
    return dfs(head);
} 